package com.chenyuxin.ilp.controller.user;

import com.chenyuxin.ilp.model.pojo.Result;
import com.chenyuxin.ilp.model.vo.user.UserLoginVo;
import com.chenyuxin.ilp.service.user.UserService;
import com.chenyuxin.ilp.util.SecurityUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;
    @GetMapping("/select/{param}")
    public Result selectUserByPhoneOrName(@PathVariable String param){
        return userService.selectUserByPhoneOrName(param);
    }
    @GetMapping("/token")
    public Result getUserInformationByToken(){
        UserLoginVo userLoginVo = SecurityUtil.getUserInformation();
        return Result.ok(userLoginVo);
    }
    @GetMapping("/{userid}")
    public Result getUserInformation(@PathVariable("userid") String userId){
        return userService.getUserInformation(userId);
    }

}
